#pragma once

#ifndef BASIC_DATA_H
#define BASIC_DATA_H

#include <math.h>
#include <vector>

namespace user_constant
{
	const double me_MeV = 0.510998910;
	const double c = 299792458;
	const double f0 = 2856e6;
};

class phase_space_point
{
public:
	double x,px,y,py,z,pz;
	double p(){return sqrt(px*px+py*py+pz*pz);}; 
};

class trace_space_point
{
public:
	double x,xp,y,yp,phi,w;
	int n;
};

class phase_space_dist
{
public:
	phase_space_dist(){size=0;};
	std::vector<phase_space_point> dataset;

	double phase;
	int size;

	void clear(){dataset.clear();};
	void set(int n){dataset.resize(n);size=n;};
};

class trace_space_dist
{
public:
	std::vector<trace_space_point> dataset;

	double phase;
	int size;

	void clear(){dataset.clear();};
	void set(int n){dataset.resize(n);size=n;};
};
	

double get_momentum_energy(double energy_MeV);
double get_momentum_beta(double beta);
double get_momentum_gamma(double gamma);
double get_momentum_kinetic(double w);

double get_kinetic_momentum(double cp_MeV);
double get_kinetic_betagamma(double betagamma);

void convert_to_phase(phase_space_point& output,trace_space_point& input,double z0=0);
void convert_to_phase(phase_space_dist& output,trace_space_dist& input,double z0=0);

void convert_to_trace(trace_space_dist& output,phase_space_dist& input);

#endif //BASIC_DATA_H